<template>
	<view class="uni_box home">
		<navbar title='提币' :yin="false">
			<view class="hright" slot="right" @click="getrightClick">
				<image class="chongji" src="/static/img/chongji.png" mode="" />
			</view>
		</navbar>
		<view class="content">
			<view class="Withdrawal-module">
				<view class="Withdrawal-top">
					<image class="usdt" src="/static/img/usdt.png" mode="" />
					<text class="Withdrawal-na me">USDT地址</text>
				</view>
				<view class="ushuru">
					<u-input @input="serchFun" v-model="address" type="text" :border="false" placeholder="输入地址"/>
				</view>
			</view>
			<view class="Withdrawal-module">
				<view class="Withdrawal-top">
					<text class="Withdrawal-name">选择网络</text>
				</view>
				<view class="ushuru" @click="xuanwang">
					<text class="xuantit" :class="wang?'xactive':''">{{wang?wang:'请选择'}}</text>
					<image class="xia" src="/static/img/xia.png" mode="" />
				</view>
			</view>
			<!-- <view class="Withdrawal-module" style="margin-bottom: 29rpx;">
				<view class="Withdrawal-top">
					<text class="Withdrawal-name">提币数量</text>
				</view>
				<view class="ushuru">
					<u-input v-model="amount" type="text" :border="false" placeholder="请输入"/>
					
				</view>
			</view> -->
			<view class="Withdrawal-module" style="margin-bottom: 29rpx;">
				<view class="Withdrawal-top">
					<text class="Withdrawal-name">提币金额</text>
				</view>
				<view class="ushuru">
					<u-input v-model="amount" :value="amount" type="text" :border="false" placeholder="请输入"/>
					<view class="all" @click="allClick">
						|  全部
					</view>
				</view>
			</view>
			<text class="Can-balance">可用余额：{{ info.data[0].money }} USDT</text>
			<!-- <view class="Withdrawal-module">
				<view class="Withdrawal-top">
					<text class="Withdrawal-name">验证码</text>
				</view>
				<view class="ushuru">
					<u-input v-model="value" type="text" :border="false" placeholder="请输入验证码"/>
					<view class="obtain">获取</view>
				</view>
			</view> -->

			<view class="sbotview">
				<text class="Handling-fees">手续费：{{ apiinfo.site.withdraw.withdraw_day_rate||'' }} USDT</text>
				<text class="Handling-fees">到账数量：0 USDT</text>
				<view class="btn" @click="getwithdraw">提现</view>
			</view>
		</view>

		<u-select v-model="bshow" :list="network" @confirm="bconfirm"></u-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:'',
				wang:'',
				bshow:false,
				blist:[
					{
						value: '1',
						label: '江'
					},
					{
						value: '2',
						label: '湖'
					}
				],
				amount:'',
				apiinfo:{
					site:{
						withdraw:{
							withdraw_day_rate:'',
							network:{}
						}
					}
				},
				network:[],
				address:'',
				amount:'',
				money:'',
				info:{
					data:[
						{money:0}
					]
				}
			}
		},
		onLoad() {

			this.getapiconfig();//配置接口
			this.getcapital();//资金
		},
		onShow() {
		},
		methods: {
			async getcapital(){
				let res = await this.$u.api.assets_statistic({
					type:'day'
				});
				this.info = res
			},
			async getapiconfig(){
				let res = await this.$u.api.apiconfig({
					// type:'day'
				});
				// console.log(res)
				this.apiinfo = res
				let data = this.apiinfo.site.withdraw.network
				let arry = []
				for(let i in data){
					let arryinfo = {}
					arryinfo.label = data[i]
					arryinfo.value = data[i]
					arry.push(arryinfo)
				}
				// console.log(arry)
				this.network = arry
			},
			async getwithdraw(){
				if(!this.address){
					this.$u.toast('请输入地址');
					return false
				}
				if(!this.wang){
					this.$u.toast('请选择网络');
					return false
				}

				if(!this.amount){
					this.$u.toast('请输入提币金额');
					return false
				}
				let res = await this.$u.api.withdraw({
					address:this.address,
					amount:this.amount,
					network:this.wang,//提现网络
					// money:this.money,//提现金额
				});
				this.$u.toast('操作成功');
				this.address = ''
				this.amount = ''
			},
			xuanwang(){
				this.bshow = true
			},
			bconfirm(e){
				console.log(e)
				this.wang = e[0].value
			},
			getrightClick(){
				this.navrouter("/pages/TPage/BiRecord?type=2");
			},
			allClick(){
				//点击全部
				console.log("+++")
				console.log(this.info.data[0].money)
				this.amount = Number(this.info.data[0].money)
			},
			serchFun(e){
				console.log(e)
				// e = e.replace(/[^\u4E00-\u9FA5|\d|\a-zA-Z|\r\n\s,.?!，。？！…—&$=()-+/*{}[\]]/g, '')
				e = e.replace(/[^u4e00-u9fa5w]/g,'')
				this.$nextTick(() => {
					this.address = e;
				});
			}

		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.chongji{
		width: 38rpx;
		height: 36rpx;
	}
	.content{
		background-color: #fff;
		padding: 30rpx 40rpx;
		.Withdrawal-module{
			display: flex;
			flex-direction: column;
			margin-bottom: 55rpx;
			.Withdrawal-top{
				display: flex;
				flex-direction: row;
				align-items: center;

			}
			.usdt{
				width: 46rpx;
				height: 46rpx;
				margin-right: 12rpx;
			}
			.Withdrawal-name{
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 30rpx;
				color: #000000;
			}
		}
		.ushuru{
			padding: 12rpx 25rpx;
			background: #F7F7F7;
			border-radius: 20rpx;
			margin-top: 24rpx;
			display: flex;
			align-items: center;
			flex-direction: row;
			min-height: 47px;
			/deep/.u-input__input{
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
			}
			.xuantit{
				color: #c0c4cc;
			}
			.xactive{
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
			}
			.xia{
				margin-left: auto;
				width: 16rpx;
				height: 10rpx;
			}
			.all{
				margin-left: 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #010101;
			}
			.obtain{
				padding: 8rpx 28rpx;
				margin-left: 30rpx;
				background: #000000;
				border-radius: 50rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #FFFFFF;
			}
		}
		.Can-balance{
			display: block;
			text-align: right;
			font-family: Source Han Sans CN;
			font-weight: 400;
			font-size: 22rpx;
			color: #010101;
			margin-bottom: 75rpx;
		}
		
		.sbotview{
			margin: 100rpx 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.Handling-fees{
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 22rpx;
				color: #010101;
				display: block;
				margin-bottom: 15rpx;


			}
			.btn{
				width: 100%;
				height: 80rpx;
				background: #030000;
				border-radius: 40rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 30rpx;
				color: #FFFFFF;
			}
		}
		// padding-bottom: 150rpx;
	}
</style>
